<?php

namespace App\Controllers;
// 创建密钥
use App\Models\UserMsgModel;
use App\Filters\AuthFilter;


class AdminController extends BaseController
{
    public function searchAll(){
        $user_id = AuthFilter::getAccessToken($this->request);

        $request = $this->request;
        $input = $request->getPost();

        $userMsgModel = new UserMsgModel();

        $data = $userMsgModel->findAll();

        return json_encode(['msg'=>'获取所有用户信息成功','data'=>$data,'code'=>200]);
    }

    public function searchDelAll(){
        $user_id = AuthFilter::getAccessToken($this->request);

        $request = $this->request;
        $input = $request->getPost();

        $userMsgModel = new UserMsgModel();

        $data = $userMsgModel->where('isDelete','1')->findAll();

        return json_encode(['msg'=>'获取所有注销用户信息成功','data'=>$data,'code'=>200]);
    }

    public function searchUseAll(){
        $user_id = AuthFilter::getAccessToken($this->request);

        $request = $this->request;
        $input = $request->getPost();

        $userMsgModel = new UserMsgModel();

        $data = $userMsgModel->where('isDelete','0')->findAll();

        return json_encode(['msg'=>'"获取所有正常用户信息成功"','data'=>$data,'code'=>200]);
    }

    public function search(){
        $user_id = AuthFilter::getAccessToken($this->request);

        $request = $this->request;
        $input = $request->getGet();


        $userMsgModel = new UserMsgModel();

        $data = $userMsgModel->like('username', $input['username'],'both')->findAll();

        return json_encode(['msg'=>'查询用户信息成功','data'=>$data,'code'=>200]);
    }
}
